package org.example;

import java.lang.ThreadGroup;
/**
 * Copyright (c) 2023-2033 All Rights Reserved
 *
 * @date: 2023/5/8
 */
public class ThreadGroupTest {
    public static void main(String[] args) {
        threadGroupBasic();
        test();
    }

    public static void threadGroupBasic() {
        ThreadGroup threadGroup1 = new ThreadGroup("group1");
        ThreadGroup threadGroup2 = new ThreadGroup("group2");
        Thread thread1 =new Thread(threadGroup1, "group1's member");
        Thread thread2 =new Thread(threadGroup2, "group2's member");
    }

    public static void test() {
        ThreadGroup threadGroup1 = new ThreadGroup("threadgroup1");
        threadGroup1.setMaxPriority(6);

        Thread thread = new Thread(threadGroup1, () -> {
            System.out.println("threadgroup name is " + Thread.currentThread().getThreadGroup().getName());
        });
        thread.setPriority(1);

        thread.getThreadGroup().getName();

        thread.start();

        Thread.currentThread().getThreadGroup().getName();
    }
}
